<template>
  <div ref="body">
    <Form :label-width="120" inline>
      <Form-item label="保障金发放年月:">
        <DatePicker type="month" v-model="queryParam.chooseTime" :clearable="true"
                    placeholder="请选择发放年月" style="width: 200px" format="yyyy-MM" @on-change="changeTime"
                    :editable="false"></DatePicker>
      </Form-item>

      <Form-item label="是否成功:">
        <c-dict-select v-model="queryParam.type" dictCode="yesorno" :width="200"/>
      </Form-item>
      <Row class="button_row">
        <span style="float: right;">
                      <Button type="primary" @click="searchQuery">查询</Button>
                <Button type="primary" class="button_item_left" @click="searchReset">重置</Button>
                </span>
      </Row>
    </Form>
    <div class="table_div">
      <vxe-table border
                 resizable
                 row-id="id"
                 :row-key="true"
                 show-overflow="tooltip"
                 highlight-hover-row
                 align="center"
                 header-align="center"
                 ref="xTree"
                 :loading="Loading"
                 :data="tableData">
        <vxe-table-column field="time" title="保障金发放年月" align="center" width="150" :formatter="Time1" fixed="left"/>
        <vxe-table-column field="cityName" title="市" align="center" width="100" fixed="left"/>
        <vxe-table-column field="countyName" title="区县" align="center" width="100" fixed="left"/>
        <vxe-table-column field="streetName" title="乡镇街道" align="center" width="100" fixed="left"/>
        <vxe-table-column field="communityName" title="社区村" align="center" width="100" fixed="left"/>
        <vxe-table-column field="assistanceType" title="救助对象类型" align="center" width="140" />
        <vxe-table-column field="householdName" title="户主姓名" align="center" width="100"/>
        <vxe-table-column field="householdIdCard" title="户主身份号码" align="center" width="150"/>
        <vxe-table-column field="name" title="姓名" align="center" width="100"/>
        <vxe-table-column field="idCard" title="身份号码" align="center" width="150"/>
        <vxe-table-column field="money" title="发放金额" align="center" width="100"/>
        <vxe-table-column field="type" title="是否成功" align="center" :formatter="type" width="100"/>
        <vxe-table-column field="errorMsg" title="推送异常信息" align="center" width="200"/>
        <vxe-table-column title="操作" align="center" width="140" fixed="right">
          <template #default="{row}">
            <Button type="default" @click="again(row.id)" v-if="row.type=='0'">重新推送</Button>
          </template>
        </vxe-table-column>
      </vxe-table>
      <Page :total="dataCount" :page-size="pageSize" show-total class="paging"
            @on-change="handleTableChange" :current="pageNo"></Page>
    </div>
  </div>
</template>

<script>
import {CommonMixin} from '@/views/common/js/CommonMixin'
import {postAction} from "@/api/request";

export default {
  name: "exerciseDockingList",
  mixins: [CommonMixin],
  data() {
    return {
      param: {},
      queryParam: {},
      Loading: true,
      url: {
        list: "/api/ac/subsistence/exerciseDockingServiceImpl/page",
        again: "/api/ac/subsistence/exerciseDockingServiceImpl/createAgain",
      },
    }
  },
  methods: {
    again: function (id) {
      this.$Modal.confirm({
        title: '确定重新发送吗？',
        onOk: () => {
          var that = this;
          postAction(that.url.again, {id: id}).then((res) => {
            if (res.data.errcode == 0) {
              //重新计算分页问题
              that.reCalculatePage(1);
              that.$Message.success("推送成功！");
            } else {
              that.$Message.error(res.data.errmsg);
            }
          });
        }
      })
    },
    type(h) {
      if (h.cellValue == '0') {
        return "否";
      } else {
        return "是";
      }
    },
    changeTime() {
      this.queryParam.time = this.DateFormat(this.queryParam.chooseTime, 'YYYY-MM-DD')
    }
  },
  created() {
    this.loadData();

  },
}
</script>

<style scoped>

</style>